<template>
	<el-dialog
		title="修改登录密码"
		:visible.sync="dialogVisible"
		width="30%"
		:before-close="handleClose">
		<el-form>
			<el-form-item>
				原密码
				<w-input
					ref="oldPW"
					v-model="ruleForm.oldPW"
					placeholder="请输入原密码"
					size="medium"
					iconType='login-passWord'
					prefix-icon="login-passWord"
					:maxlength='100'
					:regType="$fxCommon.getFxInputReg('commonCode')"
					:showPassword='true'
					@keyup.enter.native="onCellInputEnter(arguments, 'VerifyCode')"
					class="changePWInput"
				></w-input>
			</el-form-item>
			<el-form-item>
				新密码
				<w-input
					ref="newPW"
					v-model="ruleForm.newPW"
					placeholder="请输入新密码"
					size="medium"
					iconType='login-passWord'
					prefix-icon="login-passWord"
					:maxlength='100'
					:regType="$fxCommon.getFxInputReg('commonCode')"
					:showPassword='true'
					@keyup.enter.native="onCellInputEnter(arguments, 'VerifyCode')"
					class="changePWInput"
				></w-input>
			</el-form-item>
		</el-form>
		<span slot="footer" class="dialog-footer">
			<el-button @click="dialogVisible = false">取 消</el-button>
			<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
		</span>
	</el-dialog>
</template>
<script>
export default {
	name: 'fx-changePW',
	created () {
		console.log(this.$options)
	},
	data () {
		const validateHandler = (rule, value, callback) => {
			if (!value) {
				callback(new Error(rule.message))
			} else {
				callback()
			}
		}
		return {
			ruleForm: {
				newPW: '',
				oldPW: ''
			},
			rules: {
				passWord: [{ message: '请输入密码', validator: validateHandler, trigger: 'change' }]
			},
			loginType: 'username',
			authCodeImgUrl: '',
			verificationId: ''
		}
	},
	props: {
		dialogVisible: Boolean
	},
	methods: {
		doChangePW () {
			this.changePW().then(_ => {
				this.dialogVisible = false
			})
		},
		changePW (data) {
			// return this.$fxApi('auth.loginIn')({ data })
		},
		setDialogVisible (flag) {
			this.dialogVisible = flag
		},
		handleClose (done) {
			this.$confirm('确认关闭？').then(_ => {	done() }).catch(_ => { })
		}
	}
}
</script>
<style>
.changePWInput {
	width: 300px
}
</style>
